+++ /dev/null
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- class LetterChooseWidget : Widget
- {
- int CurrentChar;
- bool Locked;
- int LockRate;
- int CurrentTime;
-
- SpriteFont Font;
-
- public LetterChooseWidget(SuperPolarity game, Vector2 position) : base(game, position)
- {
- Active = false;
- CurrentChar = 65;
- Font = game.Content.Load<SpriteFont>("Fonts\\bigfont");
- LockRate = 300;
- CurrentTime = 0;
-
- InputController.Bind("moveY", HandleMovement);
- }
-
- public void HandleMovement(float value)
- {
- if (!Active) { return; }
-
- if (value > 0.8 && !Locked) {
- CurrentChar = CurrentChar + 1;
-
- if (CurrentChar > 90)
- {
- CurrentChar = 32;
- }
-
- Locked = true;
- }
-
- if (value < -0.8 && !Locked) {
- CurrentChar = CurrentChar - 1;
-
- if (CurrentChar < 32)
- {
- CurrentChar = 90;
- }
-
- Locked = true;
- }
- }
-
- public override void Update(GameTime gameTime)
- {
- base.Update(gameTime);
-
- CurrentTime = CurrentTime + gameTime.ElapsedGameTime.Milliseconds;
- if (CurrentTime > LockRate)
- {
- CurrentTime = 0;
- Locked = false;
- }
- }
-
- public string Value()
- {
- return char.ConvertFromUtf32(CurrentChar);
- }
-
- public override void Draw(SpriteBatch spriteBatch)
- {
- var color = new Color(0, 0, 0, 128);
- if (Active)
- {
- color = new Color(201, 0, 68, 255);
- }
- spriteBatch.DrawString(Font, Value(), Position, color);
- }
- }
-}